package com.mms.action.person;

import java.util.List;

import com.mms.dao.DepartmentManagementDao;
import com.mms.dao.PersonManagementDao;
import com.mms.entity.Department;
import com.mms.entity.Staff;
import com.opensymphony.xwork2.Action;

public class DismissionPersonAction implements Action{

	private int startpage;
	private int id;
	private Staff staffMess;
	private List<Staff> staffs;
	private List<Department> depmes;
	private int account;
	
	
	public int getStartpage() {
		return startpage;
	}


	public void setStartpage(int startpage) {
		this.startpage = startpage;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public List<Staff> getStaffs() {
		return staffs;
	}


	public void setStaffs(List<Staff> staffs) {
		this.staffs = staffs;
	}


	public List<Department> getDepmes() {
		return depmes;
	}


	public void setDepmes(List<Department> depmes) {
		this.depmes = depmes;
	}


	public int getAccount() {
		return account;
	}


	public void setAccount(int account) {
		this.account = account;
	}


	public Staff getStaffMess() {
		return staffMess;
	}


	public void setStaffMess(Staff staffMess) {
		this.staffMess = staffMess;
	}


	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		PersonManagementDao pmd = new PersonManagementDao();
		DepartmentManagementDao dmd = new DepartmentManagementDao();
		staffs = pmd.getStaffs(startpage);
		depmes = dmd.getDepartments();
		for(int i=0;i<staffs.size();i++){
			if(staffs.get(i).getSId()==id){
				staffMess = staffs.get(i);
				break;
			}
		}
		staffMess.setState(2);
		pmd.modifyPerson(staffMess);
		account = pmd.getcount();
		return "success";
	}

}
